#include <STC89C5xRC.H>
#include "Delay.h"
#include <STC89C5xRC.H>
#include "Timer0.h"
#include "MATRIXLED.h"

//unsigned char Animation[]={
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x3F,0x08,0x08,0x08,0x3F,0x00,0x00,0x00,0x3C,0x02,0x01,0x02,0x0C,0x02,0x01,0x02,
//0x3C,0x00,0x3F,0x21,0x21,0x12,0x0C,0x30,0x48,0x84,0x82,0x81,0x41,0xC1,0x82,0x84,
//0x48,0x30,0x00,0x00,0x21,0x23,0x25,0x29,0x31,0x21,0x00,0x3C,0x02,0x01,0x02,0x0C,
//0x02,0x01,0x02,0x3C,0x00,0x80,0x40,0x20,0x1F,0x20,0x40,0x80,
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

unsigned char code Animation2[]={0x00,0x00,0x1F,0x3C,0x1F,0x00,0x00,0x00,
0x00,0x00,0x07,0x1C,0x3F,0x60,0x00,0x00,
0x00,0x00,0x1F,0x3C,0x1F,0x00,0x00,0x00,
0x00,0x00,0x03,0x04,0x0F,0x1C,0x30,0x00};//动画往往数据量很大，所以不放在RAM里
//放在flash里，code即表示数组存放在flash里面，但放在flash里的数组不能更改（只读）


unsigned char Offset=0;
	
void main()
{	
	Timer0Init();
	MatrixLED_Init();
	while(1)
	{	
		unsigned char i;
		for(i=0;i<8;i++)
		{
			MatrixLED_ShowColumn(i,Animation2[i+Offset]);
		}
	}
}

void Timer0_Routine() interrupt 1
{
	static unsigned int T0Count; //静态局部变量，保证退出函数时不丢失
	TL0 = 0x00;		//设置定时初值
	TH0 = 0x4C;		//设置定时初值
	T0Count++;
	if(T0Count==8)
	{
		T0Count=0;
		Offset+=8;
		if(Offset>24)
		{
			Offset=0;
		}
	}
}